home *** CD-ROM | disk | FTP | other *** search
- Path: ansible.bbt.com!newsadmin
- From: mab@pathos.bbt.com (Michael A. Bridgers)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: References troubles
- Date: 20 Feb 1996 15:52:27 GMT
- Organization: BroadBand Technologies Inc.
- Message-ID: <MAB.96Feb20105227@pathos.bbt.com>
- References: <1266.6624T117T1455@himolde.no>
- NNTP-Posting-Host: 192.154.90.1
- In-reply-to: Espen.Berntsen@himolde.no's message of 20 Feb 1996 14:09:59 GMT
-
- In article <1266.6624T117T1455@himolde.no> Espen.Berntsen@himolde.no (Nameless) writes:
- > Ok, I have aslight problem with references. The problem is that I have to pass a
- > few pointers to a subroutine, where things are done to them, and then they are
- > passed back. Now, what I hoped would work was something like this
- >
- > =========== Cut cut cut ===============================
- > #include <stdio.h>
- > #include <proto/dos.h>
- > #include <proto/exec.h>
- > #include <exec/memory.h>
- >
- > void Tester(void &Testering)
- > {
- > Testering = <some value>;
- > }
- >
- > void main(void)
- > {
- > void *Test;
- >
- > Tester(Test);
- > <use the 'Test' value>
- > ...
- > }
- > ====================== cut cut cut =======================
- > Now, this of course don't work. But Ill be damned if I know how to get it to
- > work. By reading the test program you should hopefully be able to understand
- > what I mean. PLEASE can someone help..
- >
- > And no, I can't just return the value, 'cause there will be many such values.
- > And I don't want to return a structure.
- >
-
- If you are trying to program in C, the problem is that C dosen't have references.
- You need to pass a 'void**' (void-star-star).
-
- If you are trying to program in C++, you are not allowed to pass a 'void&' (a
- void reference). You *can* however, pass a 'void *&' (a void-star reference). This
- is a reference to a 'void*'. Your code would look like this:
-
- void Tester(void *&Testering)
- {
- Testering = <some value>;
- }
-
- void main(void)
- {
- void *Test;
-
- Tester(Test);
- <use the 'Test' value>
- ...
- }
- --
- ============================================================
- Michael Bridgers + Phone : (919) 405-4627
- BroadBand Technologies, Inc. _|_
- Research Triangle Park, NC ( ) email : mab@bbt.com
- ) (
- (_ _)
- |
- ============================================================
-